<?php

Class Template 
{
    private $registry;
	private $vars = array();
	private $path;

    function __construct($registry) {
        $this->registry = $registry;
		$this->path = site_path . 'views';
    }
	
	
	function set($varname, $value, $overwrite=false) 
	{
        if (isset($this->vars[$varname]) == true AND $overwrite == false) {
                trigger_error ('Unable to set var `' . $varname . '`. Already set, and overwrite not allowed.', E_USER_NOTICE);
                return false;
        }

        $this->vars[$varname] = $value;
        return true;
	}
	
	function setPath($my_path){
		$this->path = $my_path;
	}

	function remove($varname) 
	{
        unset($this->vars[$varname]);
        return true;
	}
	
	function show($name) {
        
		$my_path = $this->path . DIRSEP . $name . '.php';
        if (file_exists($my_path) == false) {
                trigger_error ('Template `' . $name . '` does not exist.', E_USER_NOTICE);
                return false;
        }

        // Load variables
        foreach ($this->vars as $key => $value) {
                $$key = $value;
        }

        include ($my_path);               
	}

}

?>